package com.sylli.oeuf.server.game.logic;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import com.sylli.oeuf.server.game.logic.invocation.DispatcherEntry;
import com.sylli.oeuf.server.game.logic.invocation.InvocationEntry;
import com.sylli.oeuf.server.game.logic.invocation.InvocationEvent;
import com.sylli.oeuf.server.game.logic.invocation.InvocationParameter;

public class Skill implements DispatcherEntrySource {
	
	protected NumberFormat formatter = new DecimalFormat("#0.0");
	
	protected String name;
	
	protected CastingTarget defaultTarget;
	
	protected Map<InvocationEvent, InvocationEntry> table = new HashMap<InvocationEvent, InvocationEntry>();
	
	@Override
	public Collection<InvocationEvent> getAvailableHandlers() {
		return table.keySet();
	}

	@Override
	public Collection<DispatcherEntry> getDispatcherEntries(
			InvocationEvent event) {
		InvocationEntry entry = table.get(event);
		HashSet<DispatcherEntry> temp = new HashSet<DispatcherEntry>();
		DispatcherEntry de = new DispatcherEntry();
		de.setAction(entry.getAction());
		de.setCondition(entry.getCondition());
		de.setParams(new InvocationParameter(0, 0, defaultTarget));
		temp.add(de);
		return temp;
	}
	
	public InvocationEntry getInvocationEntryOn(InvocationEvent event) {
		return table.get(event);
	}
	
	public Skill(String name, CastingTarget defaultTarget) {
		this.name = name;
		this.defaultTarget = defaultTarget;
	}

	public Map<InvocationEvent, InvocationEntry> getEntries() {
		return table;
	}

	public void setEntries(Map<InvocationEvent, InvocationEntry> entries) {
		this.table = entries;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public CastingTarget getDefaultTarget() {
		return defaultTarget;
	}

	public void setDefaultTarget(CastingTarget defaultTarget) {
		this.defaultTarget = defaultTarget;
	}
}
